/**
 * Created by fanfz_000 on 2015/4/11 0011.
 */
var visit_info_page = 0;
var visit_info_page_num;
var visit_info_limit = 10;
var word_page = 0;
var word_page_num;
var word_limit = 10;
var word_label_readonly = 0;
var label_info_page = 0;
var label_info_limit = 10;
var label_page_num;
var reply_page = 0;
var reply_page_num;
var reply_limit = 10;
var friend_href_page = 0;
var friend_href_page_num;
var friend_href_limit = 10;
var blog_page = 0;
var blog_page_num;
var blog_limit = 10;
var keyword_page = 0;
var keyword_page_num;
var keyword_limit = 10;
var label_click_hidden = 0;

//隐藏页面面包板
function hide_view() {
    $('#photo_modal').hide();
    $("#right_row").hide();
    $("#blog").hide();
    $("#visit_info").hide();
    $("#word").hide();
    $("#reply").hide();
    $("#label").hide();
    $("#about_me").hide();
    $("#friend_href").hide();
    $("#keyword").hide();
}
//显示页面面包板
function show_view() {
    $("#right_row").show();
    $("#blog").show();
    $("#visit_info").show();
    $("#word").show();
    $("#reply").show();
    $("#label").show();
    $("#about_me").show();
    $("#friend_href").show();
    $("#keyword").show();
}

/*头像操作 begin*/
/*显示现有头像*/
function show_photo() {
    $.ajax({
        type: "POST",
        url: APP + "/root/show_photo",
        async: true,
        dataType: "json",
        success: function (data) {
            $("#modal_photo_show").empty();
            $("#modal_photo_show").append("<img id='about_me_photo' src='" + APP + "/" + data['photo'] + "' class='img-circle img-responsive center-block' style='width:200px;height:200px'>");
        },
        error: function () {
            $("#modal_photo_show").empty();
            $("#modal_photo_show").append("<p>暂无图片</p>");
        }
    });
}
/*显示photo_modal*/
$("#update_photo").click(function () {
    hide_view();
    show_photo();
    $('#photo_modal').show();
    $("#right_row").hide();
});
/*上传头像*/
$("#upload_photo").click(function () {
    //或者您可以在事件函数中直接使用这些方法
    new AjaxUpload('upload_photo', {
        action: APP + '/root/do_upload',
        onComplete: function (file, response) {
            if (response != "") {
                show_photo();
            }
        }
    });
    $("#upload_photo").val("上传图片");
});
/*关闭photo_modal*/
$("#close_modal_photo").click(function () {
    show_view();
    $("html,body").animate({scrollTop: $("#about_me").offset().top}, 1500);
});
/*头像操作end*/

/*文章操作begin*/
/*显示文章详细信息*/
function show_word_info(Id) {
    $.ajax({
        type: "POST",
        url: APP + "/word/word_by_id_info",
        async: true,
        dataType: "json",
        data: {
            id: Id
        },
        success: function (data) {
            $("#word_id_hidden").val(Id);
            $("#word_info_table").empty();
            $("#word_info_table").append("<tr><td class='span3'><div class='input-group'><span class='input-group-addon' id='basic-addon1'>文章id</span><span class='input-group-addon' style='line-height: 20px'>" + data['word_info']['Id'] + "<span></div></td><td class='span3'><div class='input-group'><span class='input-group-addon' id='basic-addon2'>文章标题</span><input type='text' class='form-control' id='word_title' value='" + data['word_info']['title'] + "' aria-describedby='basic-addon2' readonly></div></td><td class='span3'><div class='input-group'><span class='input-group-addon' id='basic-addon3'>发布时间</span><span class='input-group-addon' style='line-height: 20px'>" + data['word_info']['datetime'] + "</span></div></td><td class='span3'><div class='input-group'><span class='input-group-addon btn-group' id='basic-addon4'>标签</span><input type='text' class='form-control' id='word_label_name' value='" + data['word_info']['label_name'] + "' aria-describedby='basic-addon4' readonly data-toggle='dropdown' aria-expanded='false'><ul class='dropdown-menu' role='menu' style='display: none; margin-left: 50px' id='typeahead'></ul></div></td></tr>");
            $("#word_info_table").append("<tr><td colspan='4'><div class='input-group' style='width: 100%;'><span class='input-group-addon' id='basic-addon5'>文</br>章</br>内</br>容</span><textarea class='form-control' rows='10' id='word_text' readonly>" + data['word_info']['text'] + "</textarea></div></td></tr>");
            $(".delete_word").attr('id', 'word_delete_' + data['word_info']['Id']);
            $("#word_label_hidden").val(data['word_info']['label_id']);
        },
        error: function () {
            $("#word_info_table").empty();
            $("#word_info_table").append("网络异常");
        }
    });
}

/*显示标签列表*/
function show_label_list_typeahead() {
    $.ajax({
        type: "POST",
        url: APP + "/label/show_label_list",
        async: true,
        dataType: "json",
        success: function (data) {
            $("#typeahead").empty();
            $.each(data, function (index, item) {
                $("#typeahead").append("<li class='typeahead_li' id='label_id_" + item['label_id'] + "'><a>" + item['label_name'] + "</a></li>")
            });
            $("#typeahead").show();
        },
        error: function () {
            $("#typeahead").empty();
        }
    });
}
/*显示文章model*/
$(document).on('click', ".show_word", function () {
    //alert($(this).attr('id'));
    var word_list = $(this).attr("Id");
    var word_id_array = word_list.split("_");
    $("#word_info_warning").empty();
    hide_view();
    show_word_info(word_id_array[3]);
    label_click_hidden = 1;
    label_add_modal_hidden();
    label_click_hidden = 0;
    $("#word_info_upset").show();
    $(".delete_word").show();
    $("#replace_word").hide();
    $("#return_word").hide();
    $('#word_info_modal').show();
});
/*点击标签输入文本框，显示标签列表*/
$(document).on('click', "#word_label_name", function () {
    if (word_label_readonly != 0) {
        show_label_list_typeahead();
    }
});
$("#word_create_label").click(function () {
    $.ajax({
        type: "POST",
        url: APP + "/label/show_label_list",
        async: true,
        dataType: "json",
        success: function (data) {
            $("#word_create_typeahead").empty();
            $.each(data, function (index, item) {
                $("#word_create_typeahead").append("<li class='typeahead_create_li' id='label_id_" + item['label_id'] + "'><a>" + item['label_name'] + "</a></li>")
            });
            $("#word_create_typeahead").show();
        },
        error: function () {
            $("#word_create_typeahead").empty();
        }
    });
});
$("#word_create_label").blur(function () {
    $("#word_create_typeahead").hide();
});
/*标签列表，记录选择label_id，隐藏列表*/
$(document).on('click', ".typeahead_li", function () {
    $("#word_label_name").val($(this).children().html());
    $("#word_label_hidden").val($(this).attr('Id').split("_")[2]);
    $("#typeahead").hide();
});
$(document).on('click', ".typeahead_create_li", function () {
    $("#word_create_label").val($(this).children().html());
    $("#word_create_label_hidden").val($(this).attr('Id').split("_")[2]);
    $("#word_create_typeahead").hide();
});
/*文章删除*/
$(document).on('click', ".delete_word", function () {
    var word_list = $(this).attr("Id");
    var word_id_array = word_list.split("_");
    var Id = word_id_array[2];
    $.ajax({
        type: "POST",
        url: APP + "/word/delete_word",
        async: true,
        dataType: "json",
        data: {
            Id: Id
        },
        success: function (data) {
            if (data > 0) {
                show_word_list(word_page, word_limit);
                $("#word_info_modal").hide();
                show_view();
                $('html,body').animate({scrollTop: $("#word").offset().top}, 1000);
            }
            else {
                alert("删除失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*文章详细信息更新*/
$("#word_info_upset").click(function () {
    word_label_readonly = 1;
    $("#word_info_upset").hide();
    $(".delete_word").hide();
    $("#replace_word").show();
    $("#return_word").show();
    $("#word_title").removeAttr("readonly");
    $("#word_label_name").removeAttr("readonly");
    $("#word_text").removeAttr("readonly");
});
/*取消修改*/
$("#return_word").click(function () {
    $("#word_info_upset").show();
    $(".delete_word").show();
    $("#replace_word").hide();
    $("#return_word").hide();
    $("#word_title").attr("readonly", true);
    $("#word_label_name").attr("readonly", true);
    $("#word_text").attr("readonly", true);
});
/*关闭word_info_modal*/
$("#close_modal_word_info").click(function () {
    $("#word_info_upset").show();
    $(".delete_word").show();
    $("#replace_word").hide();
    $("#return_word").hide();
    $("#word_info_modal").hide();
    show_view();
    label_click_hidden = 1;
    label_add_modal_hidden();
    label_click_hidden = 0;
    $('html,body').animate({scrollTop: $("#word").offset().top}, 1000);
});
/*更新文章   2015-5-4*/
$("#replace_word").click(function () {
    var word_id = $("#word_id_hidden").val();
    var word_title = $("#word_title").val();
    var label_id = $("#word_label_hidden").val();
    var word_text = $("#word_text").val();
    $.ajax({
        type: "POST",
        url: APP + "/word/update_word_by_id",
        async: true,
        dataType: "json",
        data: {
            word_id: word_id,
            word_title: word_title,
            label_id: label_id,
            word_text: word_text
        },
        success: function (data) {
            if (data > 0) {
                $("#word_info_warning").empty();
                $("#word_info_warning").append("更新成功");
                show_word_list(word_page, word_limit);
                $("#word_info_modal").hide();
                show_view();
                $('html,body').animate({scrollTop: $("#word").offset().top}, 1000);
            }
            else {
                $("#word_info_warning").empty();
                $("#word_info_warning").append("数据异常");
            }
        },
        error: function () {
            $("#word_info_warning").empty();
            $("#word_info_warning").append("网络异常");
        }
    });
});
/*打开新建文章modal   2015-5-4*/
$("#show_word_create_model").click(function () {
    $("#word_create_modal").show();
    $("#word_create_warning").empty();
    hide_view();
    label_click_hidden = 1;
    label_add_modal_hidden();
});
/*关闭新建文章modal   2015-5-4*/
$("#close_modal_word_create").click(function () {
    $("#word_create_modal").hide();
    show_view();
    $("#label_add_modal").hide();
    label_click_hidden = 1;
    label_add_modal_hidden();
    label_click_hidden = 0;
    $('html,body').animate({scrollTop: $("#word").offset().top}, 1000);
});
/*新建文章重置  2015-5-4*/
$("#word_create_reset").click(function () {
    $("#word_creae_title").val("");
    $("#word_create_label_hidden").val("");
    $("#word_create_label").val();
    $('#editor').html("");
});
/*新建文章  2015-5-4*/
$("#create_word").click(function () {
    var word_title = $("#word_creae_title").val();
    var label_id = $("#word_create_label_hidden").val();
    var word_text = $('#editor').html();
    if (word_title.length != 0 && label_id.length != 0 && word_text.length != 0) {
        $.ajax({
            type: "POST",
            url: APP + "/word/create_word",
            async: true,
            dataType: "json",
            data: {
                word_title: word_title,
                label_id: label_id,
                word_text: word_text
            },
            success: function (data) {
                if (data > 0) {
                    $("#word_create_warning").empty();
                    $("#word_create_warning").append("成功");
                    show_word_list(word_page, word_limit);
                    $("#word_create_modal").hide();
                    show_view();
                    $('html,body').animate({scrollTop: $("#word").offset().top}, 1000);
                }
                else {
                    $("#word_create_warning").empty();
                    $("#word_create_warning").append("数据异常");
                }
            },
            error: function () {
                $("#word_create_warning").empty();
                $("#word_create_warning").append("网络异常");
            }
        });
    }
    else {
        alert("请确保信息填写完成")
    }
    
});
/*文章操作end*/

/*标签操作begin*/
/*显示label_add_modal模态框  2015-5-4*/
$(".add_label").click(function () {
    $("#label_add_modal").show();
});
/*隐藏label_add_modal模态框  2015-5-4*/
$("#close_modal_label_add").click(function () {
    label_add_modal_hidden();
});
function label_add_modal_hidden() {
    if (label_click_hidden == 0) {
        $("#label_add_modal").hide();
        $("#label_add_name").val(" ");
        show_view();
        $("#label_add_modal").hide();
        $('html,body').animate({scrollTop: $("#label").offset().top}, 1000);
    }
    else {
        $("#label_add_modal").hide();
        $("#label_add_name").val(" ");
    }
}
/*重置label_add_modal模态框 2015-5-4*/
$("#label_add_reset").click(function () {
    $("#label_add_name").val("");
});
$("#show_label_create_model").click(function () {
    $("#label_add_modal").show();
    $("#label_add_warning").empty();
    hide_view();
});
/*添加label_name 2015-5-4*/
$("#label_add_btn").click(function () {
    var label_name = $("#label_add_name").val();
    $.ajax({
        type: "POST",
        url: APP + "/label/create_label",
        async: true,
        dataType: "json",
        data: {
            label_name: label_name
        },
        success: function (data) {
            if (data > 0) {
                $("#label_add_warning").empty();
                $("#label_add_warning").append("成功");
                label_click_hidden = 0;
                label_add_modal_hidden();
                label_click_hidden = 1;
                $("#word_create_typeahead").hide();
                show_label_list(label_info_page, label_info_limit);
                $("#word_create_typeahead").show();
                $('html,body').animate({scrollTop: $("#label").offset().top}, 1000);
            }
            else {
                $("#label_add_warning").empty();
                $("#label_add_warning").append("数据异常");
            }
        },
        error: function () {
            $("#label_add_warning").empty();
            $("#label_add_warning").append("网络异常");
        }
    });
});
/*标签删除*/
$(document).on('click', ".delete_label", function () {
    var delete_id = $(this).attr("Id");
    var delete_label_id = delete_id.split("_")[2];
    $.ajax({
        type: "POST",
        url: APP + "/label/delete_label",
        async: true,
        dataType: "json",
        data: {
            Id: delete_label_id
        },
        success: function (data) {
            if (data > 0) {
                show_label_list(label_info_page, label_info_limit);
            }
            else {
                alert("删除失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*标签名重命名事件触发*/
$(document).on('click', ".rename_label", function () {
    var rename_id = $(this).attr("Id");
    var rename_label_id = rename_id.split("_")[2];
    $("#label_rename_" + rename_label_id).hide();
    $("#label_delete_" + rename_label_id).hide();
    $("#label_reset_" + rename_label_id).show();
    $("#label_return_" + rename_label_id).show();
    $("#span_label_name_" + rename_label_id).hide();
    $("#input_label_name_" + rename_label_id).show();
});
/*取消修改*/
$(document).on('click', ".return_label", function () {
    var return_id = $(this).attr("Id");
    var return_label_id = return_id.split("_")[2];
    $("#label_rename_" + return_label_id).show();
    $("#label_delete_" + return_label_id).show();
    $("#label_reset_" + return_label_id).hide();
    $("#label_return_" + return_label_id).hide();
    $("#span_label_name_" + return_label_id).show();
    $("#input_label_name_" + return_label_id).hide();
});
/*标签名修改*/
$(document).on('click', ".reset_label", function () {
    var reset_id = $(this).attr("Id");
    var reset_label_id = reset_id.split("_")[2];
    $.ajax({
        type: "POST",
        url: APP + "/label/reset_label",
        async: true,
        dataType: "json",
        data: {
            Id: reset_label_id,
            label_name: $("#input_label_name_" + reset_label_id).val()
        },
        success: function (data) {
            if (data > 0) {
                show_label_list(label_info_page, label_info_limit);
            }
            else {
                alert("重命名失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*标签操作end*/

/*留言操作begin*/
/*留言删除*/
$(document).on('click', ".delete_reply", function () {
    var delete_id = $(this).attr("Id");
    var delete_reply_id = delete_id.split("_")[2];
    $.ajax({
        type: "POST",
        url: APP + "/reply/delete_reply",
        async: true,
        dataType: "json",
        data: {
            Id: delete_reply_id
        },
        success: function (data) {
            if (data > 0) {
                show_reply_list(reply_page, reply_limit);
            }
            else {
                if (data == -1)
                    alert("删除失败");
                else if (data == -2) {
                    alert("不合理操作");
                }
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*留言操作end*/

/*关于我操作begin*/
/*关于我修改切换到修改状态*/
$("#replace_about_me").click(function () {
    $("#replace_about_me").hide();
    $("#update_about_me").show();
    $("#return_about_me").show();
    $("#about_me_qq").removeAttr("readonly");
    $("#about_me_email").removeAttr("readonly");
    $("#about_me_qq_zone_title").removeAttr("readonly");
    $("#about_me_qq_zone_href").removeAttr("readonly");
    $("#about_me_sina_title").removeAttr("readonly");
    $("#about_me_sina_href").removeAttr("readonly");
    $("#about_me_renren_href").removeAttr("readonly");
    $("#about_me_renren_title").removeAttr("readonly");
    $("#about_me_city").removeAttr("readonly");
    $("#about_me_school").removeAttr("readonly");
    $("#about_me_college").removeAttr("readonly");
    $("#about_me_field").removeAttr("readonly");
    $("#about_me_sign").removeAttr("readonly");
    $("#about_me_introduce_me").removeAttr("readonly");
});
/*返回关于我状态*/
function return_about_me_table() {
    $("#replace_about_me").show();
    $("#update_about_me").hide();
    $("#return_about_me").hide();
    $("#about_me_qq").attr("readonly", true);
    $("#about_me_email").attr("readonly", true);
    $("#about_me_qq_zone_title").attr("readonly", true);
    $("#about_me_qq_zone_href").attr("readonly", true);
    $("#about_me_sina_title").attr("readonly", true);
    $("#about_me_sina_href").attr("readonly", true);
    $("#about_me_renren_href").attr("readonly", true);
    $("#about_me_renren_title").attr("readonly", true);
    $("#about_me_city").attr("readonly", true);
    $("#about_me_school").attr("readonly", true);
    $("#about_me_college").attr("readonly", true);
    $("#about_me_field").attr("readonly", true);
    $("#about_me_sign").attr("readonly", true);
    $("#about_me_introduce_me").attr("readonly", true);
    $("#return_about_me").html("取消");
}

/*取消修改*/
$("#return_about_me").click(function () {
    return_about_me_table()
});
/*关于我修改提交*/
$("#update_about_me").click(function () {
    $("#update_about_me").html("Loding..");
    var qq = $("#about_me_qq").val();
    var email = $("#about_me_email").val();
    var qq_zone_title = $("#about_me_qq_zone_title").val();
    var qq_zone_href = $("#about_me_qq_zone_href").val();
    var sina_title = $("#about_me_sina_title").val();
    var sina_href = $("#about_me_sina_href").val();
    var renren_href = $("#about_me_renren_href").val();
    var renren_title = $("#about_me_renren_title").val();
    var city = $("#about_me_city").val();
    var school = $("#about_me_school").val();
    var college = $("#about_me_college").val();
    var field = $("#about_me_field").val();
    var sign = $("#about_me_sign").val();
    var introduce_me = $("#about_me_introduce_me").val();
    $.ajax({
        type: "POST",
        url: APP + "/root/reset_about_me",
        async: true,
        data: {
            "qq": qq,
            "email": email,
            "qq_zone_title": qq_zone_title,
            "qq_zone_href": qq_zone_href,
            "sina_title": sina_title,
            "sina_href": sina_href,
            "renren_href": renren_href,
            "renren_title": renren_title,
            "city": city,
            "school": school,
            "college": college,
            "field": field,
            "sign": sign,
            "introduce_me": introduce_me
        },
        dataType: "json",
        success: function (data) {
            if (data > 0) {
                $("#update_about_me").html("更新成功");
                $("#return_about_me").html("返回");
                $(function () {
                    setTimeout(function () {
                        return_about_me_table();
                    }, 2000);
                })

            }
            else {
                $("#update_about_me").html("更新失败");
            }
        },
        error: function () {
            $("#update_about_me").html("网络异常");
        }
    });
});
/*关于我操作end*/

/*友情链接操作end*/
/*友情链接删除*/
$(document).on('click', ".delete_friend_href", function () {
    var delete_id = $(this).attr("Id");
    var delete_friend_href_id = delete_id.split("_")[3];
    $.ajax({
        type: "POST",
        url: APP + "/friendhref/delete_friend_href",
        async: true,
        dataType: "json",
        data: {
            Id: delete_friend_href_id
        },
        success: function (data) {
            if (data > 0) {
                show_friend_href_list(friend_href_page, friend_href_limit);
            }
            else {
                alert("删除失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*友情链接重命名事件触发*/
$(document).on('click', ".rename_friend_href", function () {
    var rename_id = $(this).attr("Id");
    var rename_friend_href_id = rename_id.split("_")[3];
    $("#friend_href_rename_" + rename_friend_href_id).hide();
    $("#delete_friend_href_" + rename_friend_href_id).hide();
    $("#friend_href_reset_" + rename_friend_href_id).show();
    $("#return_friend_href_" + rename_friend_href_id).show();
    $("#span_friend_href_name_" + rename_friend_href_id).hide();
    $("#span_friend_href_" + rename_friend_href_id).hide();
    $("#input_friend_href_name_" + rename_friend_href_id).show();
    $("#input_friend_href_" + rename_friend_href_id).show();
});
/*取消修改*/
$(document).on('click', ".return_friend_href", function () {
    var return_id = $(this).attr("Id");
    var return_friend_href_id = return_id.split("_")[3];
    $("#friend_href_rename_" + return_friend_href_id).show();
    $("#delete_friend_href_" + return_friend_href_id).show();
    $("#friend_href_reset_" + return_friend_href_id).hide();
    $("#return_friend_href_" + return_friend_href_id).hide();
    $("#span_friend_href_name_" + return_friend_href_id).show();
    $("#span_friend_href_" + return_friend_href_id).show();
    $("#input_friend_href_name_" + return_friend_href_id).hide();
    $("#input_friend_href_" + return_friend_href_id).hide();
});
/*友情链接修改*/
$(document).on('click', ".renset_friend_href", function () {
    var reset_id = $(this).attr("Id");
    var reset_friend_href_id = reset_id.split("_")[3];
    $.ajax({
        type: "POST",
        url: APP + "/friendhref/reset_friend_href",
        async: true,
        dataType: "json",
        data: {
            Id: reset_friend_href_id,
            friend_name: $("#input_friend_href_name_" + reset_friend_href_id).val(),
            friend_href: $("#input_friend_href_" + reset_friend_href_id).val()
        },
        success: function (data) {
            if (data > 0) {
                show_friend_href_list(friend_href_page, friend_href_limit);
            }
            else {
                alert("重命名失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*显示友情链接列表*/
$("#show_friend_href_create_model").click(function () {
    $("#friend_href_create_modal").show();
    $("#friend_href_create_warning").empty();
    hide_view();
});
$("#close_modal_friend_href_create").click(function () {
    $("#friend_href_create_modal").hide();
    $("#friend_href_create_warning").empty();
    show_view();
    $("#label_add_modal").hide();
    $('html,body').animate({scrollTop: $("#friend_href").offset().top}, 1000);
});
$("#create_friend_href").click(function () {
    $.ajax({
        type: "POST",
        url: APP + "/friendhref/new_friend_href",
        async: true,
        dataType: "json",
        data: {
            friend_name: $("#friend_href_create_title").val(),
            friend_href: $("#friend_href_create_label").val()
        },
        success: function (data) {
            if (data > 0) {
                $("#friend_href_create_modal").hide();
                $("#friend_href_create_warning").empty();
                show_view();
                $("#label_add_modal").hide();
                $('html,body').animate({scrollTop: $("#friend_href").offset().top}, 1000);
                show_friend_href_list(friend_href_page, friend_href_limit);
            }
            else {
                $("#friend_href_create_warning").html("数据异常");
            }
        },
        error: function () {
            $("#friend_href_create_warning").html("网络异常");
        }
    });
});
/*友情链接操作end*/

/*系统日志begin*/
$(document).on('click', ".delete_system_blog", function () {
    var delete_id = $(this).attr("Id");
    var delete_system_blog_id = delete_id.split("_")[3];
    $.ajax({
        type: "POST",
        url: APP + "/system_blog/delete_system_blog",
        async: true,
        dataType: "json",
        data: {
            Id: delete_system_blog_id
        },
        success: function (data) {
            if (data > 0) {
                show_blog_list(blog_page, blog_limit);
            }
            else {
                alert("删除失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*系统日志end*/

/*敏感词begin*/
$(document).on('click', ".renset_keyword", function () {
    var reset_id = $(this).attr("Id");
    var renset_keyword_id = reset_id.split("_")[3];
    $.ajax({
        type: "POST",
        url: APP + "/keywords/reset_keyword",
        async: true,
        dataType: "json",
        data: {
            Id: renset_keyword_id,
            text: $("#input_keyword_name_" + renset_keyword_id).val()
        },
        success: function (data) {
            if (data > 0) {
                show_keyword_list(keyword_page, keyword_limit);
            }
            else {
                alert("重命名失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*显示敏感词列表*/
$("#show_keyword_create_model").click(function () {
    $("#keyword_create_modal").show();
    $("#keyword_create_warning").empty();
    hide_view();
});
$("#close_modal_keyword_create").click(function () {
    $("#keyword_create_modal").hide();
    $("#keyword_create_warning").empty();
    show_view();
    $('html,body').animate({scrollTop: $("#keyword").offset().top}, 1000);
});
$("#keyword_create_reset").click(function () {
    $("#keyword_create_name").val("");
});
$("#create_keyword").click(function () {
    $.ajax({
        type: "POST",
        url: APP + "/keywords/add_keyword",
        async: true,
        dataType: "json",
        data: {
            text: $("#keyword_create_name").val()
        },
        success: function (data) {
            if (data > 0) {
                $("#keyword_create_modal").hide();
                $("#keyword_create_warning").empty();
                show_view();
                $('html,body').animate({scrollTop: $("#keyword").offset().top}, 1000);
                show_keyword_list(keyword_page, keyword_limit);
            }
            else {
                $("#keyword_create_warning").html("数据异常");
            }
        },
        error: function () {
            $("#keyword_create_warning").html("网络异常");
        }
    });
});
/*敏感词删除*/
$(document).on('click', ".delete_keyword", function () {
    var delete_id = $(this).attr("Id");
    var delete_keyword_id = delete_id.split("_")[2];
    $.ajax({
        type: "POST",
        url: APP + "/keywords/del_keyword",
        async: true,
        dataType: "json",
        data: {
            Id: delete_keyword_id
        },
        success: function (data) {
            if (data > 0) {
                show_keyword_list(keyword_page, keyword_limit);
            }
            else {
                alert("删除失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
/*标签名重命名事件触发*/
$(document).on('click', ".rename_keyword", function () {
    var rename_id = $(this).attr("Id");
    var rename_keyword_id = rename_id.split("_")[2];
    $("#keyword_rename_" + rename_keyword_id).hide();
    $("#keyword_delete_" + rename_keyword_id).hide();
    $("#keyword_reset_" + rename_keyword_id).show();
    $("#keyword_return_" + rename_keyword_id).show();
    $("#span_keyword_name_" + rename_keyword_id).hide();
    $("#input_keyword_name_" + rename_keyword_id).show();
});
/*取消修改*/
$(document).on('click', ".return_keyword", function () {
    var return_id = $(this).attr("Id");
    var return_keyword_id = return_id.split("_")[2];
    $("#keyword_rename_" + return_keyword_id).show();
    $("#keyword_delete_" + return_keyword_id).show();
    $("#keyword_reset_" + return_keyword_id).hide();
    $("#keyword_return_" + return_keyword_id).hide();
    $("#span_keyword_name_" + return_keyword_id).show();
    $("#input_keyword_name_" + return_keyword_id).hide();
});
/*敏感词修改*/
$(document).on('click', ".reset_keyword", function () {
    var reset_id = $(this).attr("Id");
    var reset_keyword_id = reset_id.split("_")[2];
    $.ajax({
        type: "POST",
        url: APP + "/keywords/reset_keyword",
        async: true,
        dataType: "json",
        data: {
            Id: reset_keyword_id,
            text: $("#input_keyword_name_" + reset_keyword_id).val()
        },
        success: function (data) {
            if (data > 0) {
                show_keyword_list(keyword_page, keyword_limit);
            }
            else {
                alert("重命名失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});
$("#upload_keyword").click(function () {
    //或者您可以在事件函数中直接使用这些方法
    new AjaxUpload('upload_keyword', {
        action: APP + '/keywords/input_keyword',
        onComplete: function (file, response) {
            if (response != "") {
                show_keyword_list(keyword_page, keyword_limit);
            }
        }
    });
    $("#upload_keyword").val("上传文件");
});
$("#distinct_keywords").click(function () {
    $.ajax({
        type: "POST",
        url: APP + "/keywords/sort_keyword",
        async: true,
        dataType: "json",
        success: function (data) {
            if (data > 0) {
                show_keyword_list(keyword_page, keyword_limit);
            }
            else {
                alert("去重失败");
            }
        },
        error: function () {
            alert("网络异常");
        }
    });
});

/*敏感词end*/

/*显示访客列表列表*/
function show_visit_info_list(visit_info_page, visit_info_limit) {
    $.ajax({
        type: "POST",
        url: APP + "/visit_info/show_visit_info",
        async: true,
        data: {
            page: visit_info_page,
            limit: visit_info_limit
        },
        dataType: "json",
        success: function (html) {
            show_visit_chart();
            if (html['total'] > 0) {
                $("#visit_info_table").empty();
                $("#visit_info_table").append("<tr><th class='text-center'>记录id</th><th class='text-center'>来访时间</th><th class='text-center'>访客ip </th></tr>");
                $.each(html["data"], function (index, item) {
                    $("#visit_info_table").append("<tr><td class='text-center' >" + item['Id'] + "</td><td class='text-center'>" + item['visit_time'] + "</td><td class='text-center'>" + item['visit_ip'] + "</td></tr>");
                });
                visit_info_page_num = Math.ceil(html['total'] / visit_info_limit);
                $("#visit_info_this_page").html(visit_info_page + 1);
                $("#visit_info_page_num").html(visit_info_page_num);
                if (visit_info_page == 0) {
                    $("#visit_info_page_pre").hide();
                }
                else {
                    $("#visit_info_page_pre").show();
                }
                if ((visit_info_page + 1) == visit_info_page_num) {
                    $("#visit_info_page_next").hide();
                }
                else {
                    $("#visit_info_page_next").show();
                }
                magic_number(html['today_total'], html['total']);
            }
            else {
                $("#visit_info_this_page").html("0");
                $("#visit_info_page_num").html("0");
                $("#visit_info_page_next").hide();
                $("#visit_info_page_pre").hide();
                $("#visit_info_table").empty();
                $("#visit_info_table").append("<p class='post-title text-center'><strong>数据加载完成</strong></p>");
            }
        },
        error: function () {
            $("#visit_info_table").empty();
            $("#visit_info_table").append("<p class='post-title text-center'>网络异常</p>");
        }
    });
}
//数字统计动态展示效果
function magic_number(value1, value2) {
    var today_total = $("#visit_info_today_total");
    var total = $("#visit_info_total");
    today_total.animate({count: value1}, {
        duration: 500,
        step: function () {
            today_total.text(String(parseInt(this.count)));
        }
    });
    total.animate({count: value2}, {
        duration: 500,
        step: function () {
            total.text(String(parseInt(this.count)));
        }
    });
}
$("#visit_info_page_pre").click(function () {
    visit_info_page = visit_info_page - 1;
    show_visit_info_list(visit_info_page, visit_info_limit);
});
$("#visit_info_page_next").click(function () {
    visit_info_page = visit_info_page + 1;
    show_visit_info_list(visit_info_page, visit_info_limit);
});

/*显示文章列表*/
function show_word_list(word_page, word_limit) {
    $.ajax({
        type: "POST",
        url: APP + "/word/word_info_list",
        async: true,
        data: {
            page: word_page,
            limit: word_limit
        },
        dataType: "json",
        success: function (html) {
            //alert(html['total']);
            if (html['total'] > 0) {
                $("#word_table").empty();
                $("#word_table").append("<tr><th class='text-center'>文章id</th><th class='text-center'>标题</th><th class='text-center'>发布时间</th><th class='text-center'>标签</th><th class='text-center'>操作</th></tr>");
                $.each(html["data"], function (index, item) {
                    $("#word_table").append("<tr><td class='text-center' style='vertical-align:middle;'>" + item['Id'] + "</td><td class='text-center' style='vertical-align:middle; '><span style='white-space:pre-wrap;'>" + item['title'] + "</span></td><td class='text-center' style='vertical-align:middle; '>" + item['datetime'] + "</td><td class='text-center' style='vertical-align:middle;'>" + item['label_name'] + "</td><td class='text-center'><button class='btn btn-primary show_word' id='word_info_id_" + item['Id'] + "' data-togle='modal' data-target='#word_info_modal'>查看详细</button></td></tr>");
                });
                word_page_num = Math.ceil(html['total'] / word_limit);
                $("#word_this_page").html(word_page + 1);
                $("#word_page_num").html(word_page_num);
                if (word_page == 0 || word_page_num == 0) {
                    $("#word_page_pre").hide();
                }
                else {
                    $("#word_page_pre").show();
                }
                if ((word_page + 1) == word_page_num) {
                    $("#word_page_next").hide();
                }
                else {
                    $("#word_page_next").show();
                }
            }
            else {
                $("#word_this_page").html("0");
                $("#word_page_num").html("0");
                $("#word_page_next").hide();
                $("#word_page_pre").hide();
                $("#word_table").empty();
                $("#word_table").append("<p class='post-title text-center'><strong>数据加载完成</strong></p>");
            }
        },
        error: function () {
            $("#word_table").empty();
            $("#word_table").append("<p class='post-title text-center'>网络异常</p>");
        }
    });
}
$("#word_page_pre").click(function () {
    visit_info_page = visit_info_page - 1;
    show_word_list(word_page, word_limit);
});
$("#word_page_next").click(function () {
    visit_info_page = visit_info_page + 1;
    show_word_list(word_page, word_limit);
});
/*显示标签列表*/
function show_label_list(label_info_page, label_info_limit) {
    $.ajax({
        type: "POST",
        url: APP + "/label/show_label_info",
        async: true,
        data: {
            page: label_info_page,
            limit: label_info_limit
        },
        dataType: "json",
        success: function (html) {
            if (html['total'] > 0) {
                $("#label_list").empty();
                $("#label_list").append("<tr><th class='text-center span3'>标签id</th><th class='text-center span3'>标签名</th><th class='text-center span3'>文章数</th><th class='text-center span3'>操作</th></tr>");
                $.each(html["data"], function (index, item) {
                    $("#label_list").append("<tr><td class='text-center' style='vertical-align:middle; '>" + item['label_id'] + "</td><td class='text-center' style='vertical-align:middle; '><span id='span_label_name_" + item['label_id'] + "'>" + item['label_name'] + "</span><input type='text' class='form-control span2' value='" + item['label_name'] + "' id='input_label_name_" + item['label_id'] + "' style='text-align:center;display:none;margin-bottom:0px'></td><td class='text-center' style='vertical-align:middle; '>" + item['word_num'] + "</td><td class='text-center'><button class='btn btn-success reset_label' id='label_reset_" + item['label_id'] + "' style='display:none;'>更新</button><button class='btn btn-primary rename_label' id='label_rename_" + item['label_id'] + "'>重命名</button><button class='btn btn-danger delete_label' id='label_delete_" + item['label_id'] + "' style='margin-left:10px'>删除</button><button class='btn btn-info return_label' id='label_return_" + item['label_id'] + "' style='margin-left:10px;display: none'>取消</button></td></tr>");
                });
                label_page_num = Math.ceil(html['total'] / label_info_limit);
                $("#label_this_page").html(label_info_page + 1);
                $("#label_page_num").html(label_page_num);
                if (label_info_page == 0) {
                    $("#label_page_pre").hide();
                }
                else {
                    $("#label_page_pre").show();
                }
                if ((label_info_page + 1) == label_page_num) {
                    $("#label_page_next").hide();
                }
                else {
                    $("#label_page_next").show();
                }
            }
            else {
                $("#label_this_page").html("0");
                $("#label_page_num").html("0");
                $("#label_page_pre").hide();
                $("#label_page_next").hide();
                $("#label_list").empty();
                $("#label_list").append("<p class='post-title text-center'><strong>数据加载完成</strong></p>");
            }
        },
        error: function () {
            $("#label_list").empty();
            $("#label_list").append("<p class='post-title text-center'>网络异常</p>");
        }
    });
}
$("#label_page_pre").click(function () {
    label_info_page = label_info_page - 1;
    show_label_list(label_info_page, label_info_limit);
});
$("#label_page_next").click(function () {
    label_info_page = label_info_page + 1;
    show_label_list(label_info_page, label_info_limit);
});
/*显示留言列表*/
function show_reply_list(reply_page, reply_limit) {
    $.ajax({
        type: "POST",
        url: APP + "/reply/reply_page",
        async: true,
        data: {
            page: reply_page,
            limit: reply_limit
        },
        dataType: "json",
        success: function (html) {
            if (html['total'] > 0) {
                $("#reply_list").empty();
                $("#reply_list").append("<tr><th class='text-center span2'>留言id</th><th class='text-center span3'>留言时间</th><th class='text-center span5'>内容</th><th class='text-center span2'>操作</th></tr>");
                $.each(html["data"], function (index, item) {
                    $("#reply_list").append("<tr><td class='text-center' style='vertical-align:middle; '>" + item['Id'] + "</td><td class='text-center' style='vertical-align:middle; '>" + item['reply_time'] + "</td><td class='text-center' style='vertical-align:middle; '><span style='vertical-align: middle;word-break:break-all; word-wrap : break-word ;overflow: hidden ;'>" + item['reply_text'] + "</span></td><td class='text-center' style='vertical-align: middle'><button class='btn btn-danger delete_reply' id='delete_reply_" + item['Id'] + "'>删除</button></td></tr>");
                });
                reply_page_num = Math.ceil(html['total'] / reply_limit);
                $("#reply_this_page").html(reply_page + 1);
                $("#reply_page_num").html(reply_page_num);
                if (reply_page == 0) {
                    $("#reply_page_pre").hide();
                }
                else {
                    $("#reply_page_pre").show();
                }
                if ((reply_page + 1) == reply_page_num) {
                    $("#reply_page_next").hide();
                }
                else {
                    $("#reply_page_next").show();
                }
            }
            else {
                $("#reply_this_page").html("0");
                $("#reply_page_num").html("0");
                $("#reply_page_pre").hide();
                $("#reply_page_next").hide();
                $("#reply_list").empty();
                $("#reply_list").append("<p class='post-title text-center'><strong>数据加载完成</strong></p>");
            }
        },
        error: function () {
            $("#reply_list").empty();
            $("#reply_list").append("<p class='post-title text-center'>网络异常</p>");
        }
    });
}
$("#reply_page_pre").click(function () {
    reply_page = reply_page - 1;
    show_reply_list(reply_page, reply_limit);
});
$("#reply_page_next").click(function () {
    reply_page = reply_page + 1;
    show_reply_list(reply_page, reply_limit);
});
/*显示友情链接列表*/
function show_friend_href_list(friend_href_page, friend_href_limit) {
    $.ajax({
        type: "POST",
        url: APP + "/friendhref/friend_href_list",
        async: true,
        data: {
            page: friend_href_page,
            limit: friend_href_limit
        },
        dataType: "json",
        success: function (html) {
            if (html['total'] > 0) {
                $("#friend_href_list").empty();
                $("#friend_href_list").append("<tr><th class='text-center span2'>友情链接id</th><th class='text-center span3'>友情链接名</th><th class='text-center span3'>友情链接href</th><th class='text-center span3'>操作</th></tr>");
                $.each(html["data"], function (index, item) {
                    $("#friend_href_list").append("<tr><td class='text-center' style='vertical-align:middle; '>" + item['Id'] + "</td><td class='text-center' style='vertical-align:middle; '><span id='span_friend_href_name_" + item['Id'] + "'>" + item['friend_name'] + "</span><input type='text' class='form-control span2' value='" + item['friend_name'] + "' id='input_friend_href_name_" + item['Id'] + "' style='text-align:center;display:none;margin-bottom:0px'></td><td class='text-center' style='vertical-align:middle; '><span id='span_friend_href_" + item['Id'] + "'>" + item['friend_href'] + "</span><input type='text' class='form-control span3' value='" + item['friend_href'] + "' id='input_friend_href_" + item['Id'] + "' style='text-align:center;margin-bottom: 0px;display:none;'></td><td class='text-center' style='vertical-align: middle'><button class='btn btn-success renset_friend_href' id='friend_href_reset_" + item['Id'] + "' style='display:none'>更新</button><button class='btn btn-primary rename_friend_href' id='friend_href_rename_" + item['Id'] + "'>重命名</button><button class='btn btn-danger delete_friend_href' id='delete_friend_href_" + item['Id'] + "' style='margin-left:10px'>删除</button><button class='btn btn-info return_friend_href' id='return_friend_href_" + item['Id'] + "' style='margin-left:10px;display:none;'>取消</button></td></tr>");
                });
                friend_href_page_num = Math.ceil(html['total'] / friend_href_limit);
                $("#friend_href_this_page").html(friend_href_page + 1);
                $("#friend_href_page_num").html(friend_href_page_num);
                if (friend_href_page == 0) {
                    $("#friend_href_page_pre").hide();
                }
                else {
                    $("#friend_href_page_pre").show();
                }
                if ((friend_href_page + 1) == friend_href_page_num) {
                    $("#friend_href_page_next").hide();
                }
                else {
                    $("#friend_href_page_next").show();
                }
            }
            else {
                $("#friend_href_this_page").html("0");
                $("#friend_href_page_num").html("0");
                $("#friend_href_page_pre").hide();
                $("#friend_href_page_next").hide();
                $("#friend_href_list").empty();
                $("#friend_href_list").append("<p class='post-title text-center'><strong>数据加载完成</strong></p>");
            }
        },
        error: function () {
            $("#friend_href_list").empty();
            $("#friend_href_list").append("<p class='post-title text-center'>网络异常</p>");
        }
    });
}
$("#friend_href_page_pre").click(function () {
    friend_href_page = friend_href_page - 1;
    show_friend_href_list(friend_href_page, friend_href_limit);
});
$("#friend_href_page_next").click(function () {
    friend_href_page = friend_href_page + 1;
    show_friend_href_list(friend_href_page, friend_href_limit);
});
/*显示日志列表*/
function show_blog_list(blog_page, blog_limit) {
    $.ajax({
        type: "POST",
        url: APP + "/system_blog/show_blog_list",
        async: true,
        data: {
            page: blog_page,
            limit: blog_limit
        },
        dataType: "json",
        success: function (html) {
            if (html['total'] > 0) {
                $("#blog_table").empty();
                $("#blog_table").append("<tr><th class='text-center span2'>日志id</th><th class='text-center span7'>日志内容</th><th class='text-center span2'>日志时间</th><th class='text-center span1'>操作</th></tr>");
                $.each(html["data"], function (index, item) {
                    $("#blog_table").append("<tr><td class='text-center' style='vertical-align:middle; '>" + item['Id'] + "</td><td class='text-center' style='vertical-align:middle; '>" + item['text'] + "</td><td class='text-center' style='vertical-align:middle; '>" + item['date'] + "</td><td class='text-center' style='vertical-align: middle'><button class='btn btn-danger delete_system_blog' id='delete_system_blog_" + item['Id'] + "'>删除</button></td></tr>");
                });
                blog_page_num = Math.ceil(html['total'] / blog_limit);
                $("#blog_this_page").html(blog_page + 1);
                $("#blog_page_num").html(blog_page_num);
                if (blog_page == 0) {
                    $("#blog_page_pre").hide();
                }
                else {
                    $("#blog_page_pre").show();
                }
                if ((blog_page + 1) == blog_page_num) {
                    $("#blog_page_next").hide();
                }
                else {
                    $("#blog_page_next").show();
                }
            }
            else {
                $("#blog_this_page").html("0");
                $("#blog_page_num").html("0");
                $("#blog_page_pre").hide();
                $("#blog_page_next").hide();
                $("#blog_table").empty();
                $("#blog_table").append("<p class='post-title text-center'><strong>数据加载完成</strong></p>");
            }
        },
        error: function () {
            $("#blog_table").empty();
            $("#blog_table").append("<p class='post-title text-center'>网络异常</p>");
        }
    });
}
$("#blog_page_pre").click(function () {
    blog_page = blog_page - 1;
    show_blog_list(blog_page, blog_limit);
});
$("#blog_page_next").click(function () {
    blog_page = blog_page + 1;
    show_blog_list(blog_page, blog_limit);
});
/*显示敏感词列表*/
function show_keyword_list(keyword_page, keyword_limit) {
    $.ajax({
        type: "POST",
        url: APP + "/keywords/show_keywords",
        async: true,
        data: {
            page: keyword_page,
            limit: keyword_limit
        },
        dataType: "json",
        success: function (html) {
            if (html['total'] > 0) {
                $("#keyword_table").empty();
                $("#keyword_table").append("<tr><th class='text-center span2'>敏感词id</th><th class='text-center span7'>敏感词</th><th class='text-center span3'>操作</th></tr>");
                $.each(html["data"], function (index, item) {
                    $("#keyword_table").append("<tr><td class='text-center' style='vertical-align:middle; '>" + item['Id'] + "</td><td class='text-center' style='vertical-align:middle; '><span id='span_keyword_name_" + item['Id'] + "'>" + item['badword'] + "</span><input type='text' class='form-control span2' value='" + item['badword'] + "' id='input_keyword_name_" + item['Id'] + "' style='text-align:center;display:none;margin-bottom:0px'></td><td class='text-center'><button class='btn btn-success reset_keyword' id='keyword_reset_" + item['Id'] + "' style='display:none;'>更新</button><button class='btn btn-primary rename_keyword' id='keyword_rename_" + item['Id'] + "'>重命名</button><button class='btn btn-danger delete_keyword' id='keyword_delete_" + item['Id'] + "' style='margin-left:10px'>删除</button><button class='btn btn-info return_keyword' id='keyword_return_" + item['Id'] + "' style='margin-left:10px;display: none'>取消</button></td></tr>");
                });
                keyword_page_num = Math.ceil(html['total'] / keyword_limit);
                $("#keyword_this_page").html(keyword_page + 1);
                $("#keyword_page_num").html(keyword_page_num);
                if (keyword_page == 0) {
                    $("#keyword_page_pre").hide();
                }
                else {
                    $("#keyword_page_pre").show();
                }
                if ((keyword_page + 1) == keyword_page_num) {
                    $("#keyword_page_next").hide();
                }
                else {
                    $("#keyword_page_next").show();
                }
            }
            else {
                $("#keyword_this_page").html("0");
                $("#keyword_page_num").html("0");
                $("#keyword_page_pre").hide();
                $("#keyword_page_next").hide();
                $("#keyword_table").empty();
                $("#keyword_table").append("<p class='post-title text-center'><strong>数据加载完成</strong></p>");
            }
        },
        error: function () {
            $("#keyword_table").empty();
            $("#keyword_table").append("<p class='post-title text-center'>网络异常</p>");
        }
    });
}
$("#keyword_page_pre").click(function () {
    keyword_page = keyword_page - 1;
    show_keyword_list(keyword_page, keyword_limit)
});
$("#keyword_page_next").click(function () {
    keyword_page = keyword_page + 1;
    show_keyword_list(keyword_page, keyword_limit)
});
function GetDateStr(AddDayCount) {
    var dd = new Date();
    dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
    var y = dd.getFullYear();
    var m = dd.getMonth() + 1;//获取当前月份的日期
    var d = dd.getDate();
    return y + "-" + m + "-" + d;
}
/*显示来访记录图表*/
function show_visit_chart() {
    var ctx = $("#visit_chart").get(0).getContext("2d");
    var visit_total_array = [];
    var i = 0;
    $.ajax({
        type: "POST",
        url: APP + "/visit_info/show_visit_total",
        async: false,
        dataType: "json",
        success: function (data) {
            $.each(data, function (index, item) {
                visit_total_array[i] = item;
                i = i + 1;
            });
        },
        error: function () {
            visit_total_array = [0, 0, 0, 0, 0, 0, 0];
        }

    });
    var data = {
        labels: [GetDateStr(-6), GetDateStr(-5), GetDateStr(-4), GetDateStr(-3), GetDateStr(-2), GetDateStr(-1), GetDateStr(0)],
        datasets: [
            {
                fillColor: "rgba(220,220,220,0.5)",
                strokeColor: "rgba(220,220,220,1)",
                pointColor: "rgba(220,220,220,1)",
                pointStrokeColor: "#fff",
                data: [0, 0, 0, 0, 0, 0, 0]
            },
            {
                fillColor: "rgba(151,187,205,0.5)",
                strokeColor: "rgba(151,187,205,1)",
                pointColor: "rgba(151,187,205,1)",
                pointStrokeColor: "#fff",
                data: visit_total_array
            }
        ]
    };
    var options = {

        //Boolean - If we show the scale above the chart data
        scaleOverlay: false,

        //Boolean - If we want to override with a hard coded scale
        scaleOverride: false,

        //** Required if scaleOverride is true **
        //Number - The number of steps in a hard coded scale
        scaleSteps: null,
        //Number - The value jump in the hard coded scale
        scaleStepWidth: null,
        //Number - The scale starting value
        scaleStartValue: null,

        //String - Colour of the scale line
        scaleLineColor: "rgba(0,0,0,.1)",

        //Number - Pixel width of the scale line
        scaleLineWidth: 1,

        //Boolean - Whether to show labels on the scale
        scaleShowLabels: false,

        //Interpolated JS string - can access value
        scaleLabel: "<%=value%>",

        //String - Scale label font declaration for the scale label
        scaleFontFamily: "'Arial'",

        //Number - Scale label font size in pixels
        scaleFontSize: 12,

        //String - Scale label font weight style
        scaleFontStyle: "normal",

        //String - Scale label font colour
        scaleFontColor: "#666",

        ///Boolean - Whether grid lines are shown across the chart
        scaleShowGridLines: true,

        //String - Colour of the grid lines
        scaleGridLineColor: "rgba(0,0,0,.05)",

        //Number - Width of the grid lines
        scaleGridLineWidth: 1,

        //Boolean - Whether the line is curved between points
        bezierCurve: true,

        //Boolean - Whether to show a dot for each point
        pointDot: true,

        //Number - Radius of each point dot in pixels
        pointDotRadius: 3,

        //Number - Pixel width of point dot stroke
        pointDotStrokeWidth: 1,

        //Boolean - Whether to show a stroke for datasets
        datasetStroke: true,

        //Number - Pixel width of dataset stroke
        datasetStrokeWidth: 2,

        //Boolean - Whether to fill the dataset with a colour
        datasetFill: true,

        //Boolean - Whether to animate the chart
        animation: true,

        //Number - Number of animation steps
        animationSteps: 30,

        //String - Animation easing effect
        animationEasing: "easeOutQuart",

        //Function - Fires when the animation is complete
        onAnimationComplete: null

    };

    var myNewChart = new Chart(ctx).Line(data, options);
}

show_word_list(word_page, word_limit);
show_visit_info_list(visit_info_page, visit_info_limit);
show_label_list(label_info_page, label_info_limit);
show_reply_list(reply_page, reply_limit);
show_friend_href_list(friend_href_page, friend_href_limit);
show_blog_list(blog_page, blog_limit);
show_keyword_list(keyword_page, keyword_limit);

$("#buckup_db").click(function () {
    $.ajax({
        type: "post",
        url: APP + "/root/backup",
        async: true,
        dataType: "json"
    });
});